package greatwall.myreader;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import com.iximo.openAPI.impl.IximoOpenAPIGetImpl;
import com.iximo.util.OpenAPIClient;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class chaptercontent extends Activity{
	private TextView contentTv;
	private ProgressDialog progressDialog;
	private OpenAPIClient XiMoClient = OpenAPIClientFactory.GetInstance();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.content);
		progressDialog = ProgressDialog.show(chaptercontent.this, 
			    "Loading...", "Please wait...", true, false);  
		contentTv=(TextView)findViewById(R.id.content);
		Intent intent=getIntent();
		String value=intent.getStringExtra("chapterID");
		 getcontent(value);
		
	}
private void getcontent(String chapterID){
    	
    	try {
			String string=XiMoClient.get_book_chapter_content(chapterID,"");
			InputStream is = new ByteArrayInputStream(string.getBytes());
    		IximoOpenAPIGetImpl iximoimpl = new IximoOpenAPIGetImpl();
    		String content=iximoimpl.getChapterContentData(is);
    		contentTv.setText(content);
    		progressDialog.dismiss();
		} catch (Exception e) {
			contentTv.setText("谢谢观看！");
		}
		
    }

}
